import unittest
from genBase import *

class Test(unittest.TestCase):


    def testFindValues(self):
        test1 = "\x00\x00\x00\x01\x00\x00\x00"
        test2 = ""
        test3 = "\x00"
        test4 = "\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00"
        test5 = "\x01\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x01"
        test6 = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
        gb = genBase()
        results = gb.findValues(1, 0, test1)
        self.assertEqual(results[0].originalValue, 1)
        self.assertEqual(results[1].originalValue, 1)

        results = gb.findValues(1, 1, test2)
        self.assertListEqual(results, [])
        
        results = gb.findValues(2, 1, test1)
        self.assertEqual(results[0].originalValue, 1)
        self.assertEqual(results[1].originalValue, 1)

        results = gb.findValues(1, 1, test3)
        self.assertListEqual(results, [])
        
        results = gb.findValues(1, 1, test4)
        self.assertEqual(results[0].originalValue, 1)
        self.assertEqual(results[1].originalValue, 1)
        self.assertEqual(len(results), 2)
        
        results = gb.findValues(1, 0, test5)
        self.assertEqual(len(results), 4)

        results = gb.findValues(1, 0, test6)
        self.assertEqual(len(results), 2)
        self.assertEqual(type(results[0]), word64)
        self.assertEqual(type(results[1]), word64)
        
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()